﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

public partial class ContactUs : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string mailBody = string.Empty;
        mailBody += @"<table border='0' cellpadding='0' cellspacing='0'>
                        <tr>
                            <td>
                                Name
                            </td>
                            <td>
                                " + txtFirstName.Text + " " + txtLastName.Text;
        mailBody += @"</td>
                        </tr>
                        <tr>
                            <td>
                                Email
                            </td>
                            <td>
                                " + txtEmail.Text;
        mailBody += @"</td>
                        </tr>
                        <tr>
                            <td>
                                Phone
                            </td>
                            <td>
                                " + txtPhone.Text;
        mailBody += @"</td>
                        </tr>
                        <tr>
                            <td>
                                Hear from
                            </td>
                            <td>
                                " + drpHearUs.SelectedItem.Text;
        mailBody += @"</td>
                        </tr>
                        <tr>
                            <td>
                                Description
                            </td>
                            <td>
                                " + txtDescription.Text;
        mailBody += @"</td>
                        </tr>
                </table>";

        CDB.LinqModel.CDBGeneral.sendEmailToUsers(ConfigurationManager.AppSettings.Get("ContactEmailTo"), "CDB Contact Us", mailBody, string.Empty);

        mailBody = string.Empty;

        mailBody = "Thanks, You have successfully reached us. One of our executive is studying your requirement and will get in touch with you in a short time.<br /><br /><br/> Thanks,<br /> CDB Service.";
        CDB.LinqModel.CDBGeneral.sendEmailToUsers(txtEmail.Text, "Thank You for Contacting CDB", mailBody, string.Empty);

        clearControls();
    }
    private void clearControls()
    {
        txtFirstName.Text = string.Empty;
        txtLastName.Text = string.Empty;
        txtEmail.Text = string.Empty;
        txtPhone.Text = string.Empty;
        drpHearUs.SelectedIndex = -1;
        txtDescription.Text = string.Empty;
    }
}